<template>
	<view>
		<cu-custom :bgLinerBorder="true" :isBlack="false">
			<block slot="content">客户详情</block>
		</cu-custom>
		<!-- <view class="contents" v-if="type==1">
			<view class="flex align-center">
				<view class="flex align-center flex-none">
					<image :src="info.photo?info.photo:'/static/img/headimg.png'" class="headimg" mode=""></image>
				</view>
				<view class="flex-1 p-l-10 f-16 fontBold orange">
					{{info.name}}
				</view>
			</view>
			<view class="m-t-10 f-16 fontBold">
				{{info.describe}}
			</view>
			<view class="m-t-10 f-16 fontBold">
				从事行业：{{info.industry}}
			</view>
			<view class="m-t-10 f-16 fontBold">
				企业规模：{{info.scale}}
			</view>
			<view class="m-t-10 f-16 fontBold">
				联系方式：{{info.username}}
			</view>
		</view> -->
		<view class="contents">
			<view class="flex align-center">
				<view class="flex align-center flex-none">
					<image :src="info.photo?info.photo:'/static/img/headimg.png'" class="headimg" mode=""></image>
				</view>
				<view class="flex-1 p-l-10 f-16 fontBold orange">
					{{info.name}}
				</view>
			</view>
			<view class="m-t-10 f-16 fontBold">
				人数：{{info.user_num}}人
			</view>
			<view class="m-t-10 f-16 fontBold">
				时间：{{info.book_at}}
			</view>
			<view class="m-t-10 f-16 fontBold">
				包间：{{info.compartment_name}}
			</view>
			<view class="m-t-10 f-16 fontBold">
				车牌：{{info.car_num}}
			</view>
			<view class="m-t-10 f-16 fontBold">
				联系：{{info.phone}}
			</view>
		</view>
		<view class="fix-btn flex flex-direction align-center justify-center" @click="toLog">
			<view class="fontBold">
				点 餐
			</view>
			<view class="fontBold">
				记 录
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// type:1,//1 tabbar列表进入  2餐厅接单进入
				id:0,
				info:{}
			}
		},
		onLoad(option) {
			// if(option.type){
			// 	this.type = option.type;
			// }
			if(option.mid){
				this.id = option.mid;
			}
			let id = this.getUrlId();
			if(id){
				this.id = this.decodeId(id);
			}
			setTimeout(()=>{
				if(this.id&&this.$store.state.shareId==null){
					this.$store.state.shareId = this.id;
				}else{
					this.$store.state.shareId=null;
				}
				this.getInfo();
			},150)
		},
		methods: {
			decodeId(base64Str) {
			  // 如果是浏览器环境，尝试用 atob
			  if (typeof atob === "function") {
			    return parseInt(atob(base64Str), 10);
			  }
			  // 如果是微信浏览器（或Node.js），用 Buffer（需确保Buffer可用）
			  else if (typeof Buffer === "function") {
			    return parseInt(Buffer.from(base64Str, "base64").toString("utf8"), 10);
			  }
			  // 如果都不支持，手动实现一个简单Base64解码（仅适用于数字）
			  else {
			    const base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
			    let decodedStr = "";
			    let buffer = 0, bits = 0;
			    
			    for (let i = 0; i < base64Str.length; i++) {
			      const char = base64Str[i];
			      if (char === "=") break; // 忽略填充符
			      const index = base64Chars.indexOf(char);
			      if (index === -1) continue; // 忽略非法字符
			      
			      buffer = (buffer << 6) | index;
			      bits += 6;
			      
			      if (bits >= 8) {
			        bits -= 8;
			        decodedStr += String.fromCharCode((buffer >> bits) & 0xff);
			      }
			    }
			    
			    return parseInt(decodedStr, 10);
			  }
			},
			getUrlId() {
				var url = new URL(window.location.href);
				var searchParams = url.searchParams;
				return searchParams.get('id');
			},
			toLog(){
				// if(this.type == 1){
				// 	uni.navigateTo({
				// 		url:'/pages/other/dineLog?type='+this.type+'&id='+this.id
				// 	})
				// }else{
					uni.navigateTo({
						url:'/pages/other/dineLog?id='+this.id
					})
				// }
			},
			getInfo(){
				// let data = {
				// 	user_id:this.id
				// }
				// let url = '/apimanager/User/managerBelowUserInfo';
				// if(this.type == 2){
					let data = {
						order_id:this.id
					}
					let url = '/apimanager/shop_manager/userOrderInfo';
				// }
				this.$http(url,data).then(res=>{
					if(res.code == 200){
						let datas = res.data;
						this.info = datas.info;
					}
				})
			},
		}
	}
</script>

<style lang="less">
	.headimg{
		width: 84rpx;
		height: 84rpx;
		border-radius: 50%;
	}
	.fix-btn{
		width: 120rpx;
		height: 120rpx;
		background: #FFCB00;
		box-shadow: 0px 3px 6px rgba(0,0,0,0.16);
		border-radius: 50%;
		color: #fff;
		position: fixed;
		bottom: 200rpx;
		right: 30rpx;
	}
</style>
